<?php
/*
Auth:Sang
Desc:日志写入文件
Date:2014-11-01
*/
namespace Lib;
use Lib\Log;
class Loger extends Log{
	private $file_name;
	public function __construct($prefix=''){
		if($prefix){
			$this->file_name = LOG_PATH.$prefix.'_'.date('Y-m-d').'.log';
		}else{
			$this->file_name = LOG_PATH.date('Y-m-d').'.log';
		}
	}
	public function put($msg,$level=self::INFO){
		if(is_array($msg)){
			$msg = var_export($msg,true);
		}
		$log = $this->format($msg,$level);
		$dir = dirname($this->file_name);
		if(!is_dir($dir)){
			mkdir($dir,0755,true);
		}
		$ofile = fopen($this->file_name, 'a');
		fwrite($ofile, $log);
		fclose($ofile);
	}
}